<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Listagem</title>
    </h:head>
    <h:body>
        <h:form id="listagemForm">
            <p:growl
                id="growl"
                showDetail="true"
                sticky="false"/>
            <p:dataTable 
                value="#{contatoBean.contatos}"
                var="contato">

                <p:column headerText="Nome">
                    <h:outputText value="#{contato.nome}"/>
                </p:column>
                <p:column headerText="Email">
                    <h:outputText value="#{contato.email}"/>
                </p:column>
                <p:column headerText="Telefone">
                    <h:outputText value="#{contato.telefone}"/>
                </p:column>

                <p:column headerText="Operações">
                    <p:commandButton ajax="false"
                                     value="Editar"
                                     action="#{contatoBean.editar}">

                        <f:setPropertyActionListener target="#{contatoBean.contato}"
                                                     value="#{contato}"/>
                    </p:commandButton>

                    <p:commandButton ajax="false"
                                     value="excluir"
                                     action="#{contatoBean.excluir()}">

                        <f:setPropertyActionListener target="#{contatoBean.contato}"
                                                     value="#{contato}"/>
                    </p:commandButton>
                </p:column>
            </p:dataTable>
            
            <p:commandButton ajax="false"
                             value="Incluir"
                             action="#{contatoBean.incluir}"
                             />
        </h:form>
    </h:body>
</html>

